package com.franz.noteapp.nav

import androidx.compose.runtime.Composable
import androidx.navigation.NavHostController
import androidx.navigation.NavType
import androidx.navigation.compose.NavHost
import androidx.navigation.compose.composable
import androidx.navigation.navArgument
import com.franz.noteapp.compose.editNote.compose.EditNotePage
import com.franz.noteapp.compose.showNotes.compose.ShowNotePage

@Composable
fun NavigationGraph(navHostController: NavHostController){
    NavHost(navController = navHostController , startDestination = NavigationItem.ShowNote.route){
        composable(NavigationItem.ShowNote.route){
            ShowNotePage(navController = navHostController)
        }
        composable(
            NavigationItem.EditNote.route+"?noteId={noteId}&noteColor={noteColor}",
            arguments = listOf(
                navArgument(
                    name = "noteId"
                ){
                    type = NavType.IntType
                    defaultValue = -1
                },
                navArgument(
                    name = "noteColor"
                ){
                    type = NavType.IntType
                    defaultValue = -1
                }
            ))
        {
            val color = it.arguments?.getInt("noteColor") ?: -1
            EditNotePage(navHostController = navHostController, color = color)
        }
    }
}